<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>论坛彩色文字生成工具</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<style type="text/css">
<!--

}
body {
	margin-top: 5px;
}
.style2 {color: #990000}
a:link {
	text-decoration: none;
	color: #0000FF;
}
a:visited {
	text-decoration: none;
	color: #0000FF;
}
a:hover {
	text-decoration: none;
	color: #006600;
}
a:active {
	text-decoration: none;
	color: #0000FF;
}
.STYLE3 {font-weight: bold}
-->
</style>
<SCRIPT language=JavaScript1.2>
<!--
var bName=navigator.appName;
var bVer=parseInt(navigator.appVersion);
var NS4=(bName=="Netscape" && bVer >= 4);
var IE4=(bName=="Microsoft Internet Explorer" && bVer >= 4);
var fstr_r;
var fstr_g;
var fstr_b;
var sItem="S";

function display(id, str){
  if(NS4 || IE4){
    if(NS4){
      with (document[id].document){
        open(); write(str); close();
      }
    }else document.all[id].innerHTML=str;
  }else{
    document.fsample2.startcolor.value=document.GradForm.start.value;
    document.fsample2.endcolor.value=document.GradForm.end.value;
  }
}

function makeArray(){
  for(i = 0; i<makeArray.arguments.length; i++)
    this[i] = makeArray.arguments[i];
}

var convert = new makeArray('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');

function returnBase(number,base) {
  eval("var output=parseInt(number)");
  if(isNum(number,base)){
    if(number < base) output = convert[output];
    else{
      var MSD = '' + Math.floor(number / base);
      var LSD = number - MSD*base;
      if(MSD > base) output = returnBase(MSD,base) + convert[LSD];
      else output = convert[MSD] + convert[LSD];
    }
  }else{
    output=0;
  }
  return output;
}

function isNum(no, base){
  var cmp="0123456789";
  var chkStr=no;
  var chkChar;
  var rc=true;
  var nLen;

  if(base == 16){
    cmp+="ABCDEFabcdef";
  }else if(base == 10){
    eval("chkStr=''+parseInt(chkStr)");
  }
  nLen=chkStr.length;

  for(var i=0; i<nLen; i++){
     chkChar=chkStr.substring(i,i+1)
     if(i==0 && chkChar == "#" && base == 16){
     }else if(cmp.indexOf(chkChar)<0){
       rc=false;
     }
     if(rc == false) i=nLen;
  }
  return rc;
}

function chkNum(obj,base){
  var form=document.GradForm;
  var rc=true;

  if(base==10){
    eval("rc=form."+obj+".value <= 255");
  }

  if(rc){
    eval("rc=isNum(form."+obj+".value,"+base+")");
    if(!rc){
      alert("输入的数值不正确！");
      eval("form."+obj+".focus()");
    }
  }else{
    alert("输入的数值大于255！");
    eval("form."+obj+".focus()");
  }
  return rc;
}

function twobyte(no){
  var str=no;

  if(isNum(no,16)){
    str="0"+str;
    str=str.substring((str.length-3)+1);
  }else{
    str="00";
  }
  return str;
}

function CstrLen(cStr){
  var sLen=cStr.length;
  var j=0;
  for(var i=0;i<sLen;i++){
     str=cStr.charAt(i);
     if(NS4 && str.charCodeAt(0)<1){
       i++;
     }
     j++;
  }
  return j;
}

function GradientText(form, color1, color2, color3, gStr, gType){
  var redStep, greenStep, BlueStep;
  var str_r, str_g, str_b, str;

  var gStep=CstrLen(gStr);

  var b1 = color1 % 0x100; if(isNaN(b1)) b1=0;
  var g1 = parseInt(color1 / 0x100) % 0x100; if(isNaN(g1)) g1=0;
  var r1 = parseInt(color1 / 0x10000) % 0x100; if(isNaN(r1)) r1=0;

  var b2 = color2 % 0x100; if(isNaN(b2)) b2=0;
  var g2 = parseInt(color2 / 0x100) % 0x100; if(isNaN(g2)) g2=0;
  var r2 = parseInt(color2 / 0x10000) % 0x100; if(isNaN(r2)) r2=0;

  var cStepAdd = parseInt(256 / gStep);

  if(g1 > g2){
    greenStep = 0;
  }else if(g2 > g1){
    greenStep = 1;
  }else{
    greenStep = 2;
  }

  if(r1 > r2){
    redStep = 0;
  }else if(r2 > r1){
    redStep = 1;
  }else{
    redStep = 2;
  }

  if(b1 > b2){
    BlueStep = 0;
  }else if(b2 > b1){
    BlueStep = 1;
  }else{
    BlueStep = 2;
  }

  var GradStr="";
  if(gType == 'S'){
    GradStr+='<TABLE WIDTH="100%" BORDER=0 CELLSPACING=0 CELLPADDING=0><TR><TD ALIGN=CENTER BGCOLOR="'+color3+'"><br>';
  }

  for(var i=0; i<gStr.length; i++){
     str_r=twobyte(returnBase(r1,16));
     str_g=twobyte(returnBase(g1,16));
     str_b=twobyte(returnBase(b1,16));

     str=gStr.charAt(i);
     if(NS4 && str.charCodeAt(0)<1){
       str=str+gStr.charAt(i+1);
       i++;
     }

     GradStr+='[color=#'+str_r+str_g+str_b+']'+str+'[/color]';

     if(redStep==1){
       r1 = r1 + cStepAdd;
       if(r1 > r2) r1 = r2;
     }else if(redStep==0){
       r1 = r1 - cStepAdd;
       if(r1 < r2) r1 = r2;
     }
        
     if(greenStep==1){
       g1 = g1 + cStepAdd;
       if(g1 > g2) g1 = g2;
     }else if(greenStep==0){
       g1 = g1 - cStepAdd;
       if(g1 < g2) g1 = g2;
     }

     if(BlueStep==1){
       b1 = b1 + cStepAdd;
       if(b1 > b2) b1 = b2;
     }else if(BlueStep==0){
       b1 = b1 - cStepAdd;
       if(b1 < b2) b1 = b2;
     }
  }

  if(gType == 'S'){
    GradStr+='<br>&nbsp;</TD></TR></TABLE>';
  }

  return GradStr;
}

function GenTag(form){
  var ss,ee,bb;

  if(!isNum(form.start.value,16)){
    alert("请检查起始颜色数值");
  }else if(!isNum(form.end.value,16)){
    alert("请检查结束颜色数值");
  }else if(!isNum(form.bg.value,16)){
    alert("请检查背景颜色数值");
  }else{
    eval("ss=0x"+form.start.value.substring(1)+";");
    eval("ee=0x"+form.end.value.substring(1)+";");
    eval("bb=form.bg.value");
    form.code.value=GradientText(form,ss,ee,bb,form.showstr.value,"C");
  }
}

function newRGB(type, field2){
  var form=document.GradForm;
  var chkOK=true;
  var vNo;

  if(field2==""){
    if(sItem=="S"){
      chkOK=chkNum('start',16);
    }else if(sItem=="E"){
      chkOK=chkNum('end',16);
    }else if(sItem=="B"){
      chkOK=chkNum('bg',16);
    }
  }

  if(chkOK){
    if(type==0){
      if(field2 != "") eval("chkOK=isNum(form.rgb_"+field2+".value,10)");
      if(chkOK){
        if(field2 != "") eval("chkOK=chkNum('rgb_"+field2+"',10)");
        if(chkOK){
          fstr_r=twobyte(returnBase(form.rgb_r.value,16));
          fstr_g=twobyte(returnBase(form.rgb_g.value,16));
          fstr_b=twobyte(returnBase(form.rgb_b.value,16));
          if(sItem=="S"){
            form.start.value="#"+fstr_r+fstr_g+fstr_b;
          }else if(sItem=="E"){
            form.end.value="#"+fstr_r+fstr_g+fstr_b;
          }else if(sItem=="B"){
            form.bg.value="#"+fstr_r+fstr_g+fstr_b;
          }
        }
      }else{
        alert("输入的颜色数值不正确。");
        eval("form.rgb_"+field2+"s.focus()");
      }
    }else{
      if(sItem=="S"){
        fstr_r=form.start.value.substring(1,3);
        fstr_g=form.start.value.substring(3,5);
        fstr_b=form.start.value.substring(5,7);
      }else if(sItem=="E"){
        fstr_r=form.end.value.substring(1,3);
        fstr_g=form.end.value.substring(3,5);
        fstr_b=form.end.value.substring(5,7);
      }else if(sItem=="B"){
        fstr_r=form.bg.value.substring(1,3);
        fstr_g=form.bg.value.substring(3,5);
        fstr_b=form.bg.value.substring(5,7);
      }
      form.rgb_r.value=parseInt(fstr_r,16);
      form.rgb_g.value=parseInt(fstr_g,16);
      form.rgb_b.value=parseInt(fstr_b,16);
    }
    if(chkOK) AddText();
  }
}

function AddText(){
  var form=document.GradForm;
  var ss,ee,bb;

  eval("ss=0x"+form.start.value.substring(1)+";");
  eval("ee=0x"+form.end.value.substring(1)+";");
  eval("bb=form.bg.value");

  str=GradientText(form,ss,ee,bb,form.showstr.value,"S");
  display("fsample", str);
}

function setRGB(id,no){
  var form=document.GradForm;
  var nid="rgb_"+id;

  if(id){
    var tmp=eval("parseInt(form."+nid+".value)+parseInt("+no+")");
    if(tmp<0) tmp=255;
    else if(tmp>255) tmp=0;

    eval("form."+nid+".value="+tmp);
  }

  fstr_r=twobyte(returnBase(form.rgb_r.value,16));
  fstr_g=twobyte(returnBase(form.rgb_g.value,16));
  fstr_b=twobyte(returnBase(form.rgb_b.value,16));

  if(sItem=="S"){
    form.start.value="#"+fstr_r+fstr_g+fstr_b;
  }else if(sItem=="E"){
    form.end.value="#"+fstr_r+fstr_g+fstr_b;
  }else if(sItem=="B"){
    form.bg.value="#"+fstr_r+fstr_g+fstr_b;
  }

  AddText();
}

function SetColor(clr){
  if(sItem=="S"){
    document.GradForm.start.value="#"+clr;
  }else if(sItem=="E"){
    document.GradForm.end.value="#"+clr;
  }else if(sItem=="B"){
    document.GradForm.bg.value="#"+clr;
  }

  ResetValue();
  AddText();
}

function set(swtch){
  if(swtch == 1) sItem="S";
  else if (swtch == 2) sItem="E";
  else if (swtch == 0) sItem="B";
  ResetValue();
}

function ResetValue(){
  var form=document.GradForm;
  var str_r, str_g, str_b;

  if(sItem=="S"){
    str_r=form.start.value.substring(1,3);
    str_g=form.start.value.substring(3,5);
    str_b=form.start.value.substring(5,7);
  }else if(sItem=="E"){
    str_r=form.end.value.substring(1,3);
    str_g=form.end.value.substring(3,5);
    str_b=form.end.value.substring(5,7);
  }else if(sItem=="B"){
    str_r=form.bg.value.substring(1,3);
    str_g=form.bg.value.substring(3,5);
    str_b=form.bg.value.substring(5,7);
  }
  form.rgb_r.value=parseInt(str_r,16);
  form.rgb_g.value=parseInt(str_g,16);
  form.rgb_b.value=parseInt(str_b,16);
}

function nomsg(){
  self.status="";
}

function myReset(){
  AddText();
}

//-->
</SCRIPT>
</HEAD>
<BODY>
<TABLE cellSpacing=0 borderColorDark=#ffffff cellPadding=2 width=613 
align=center borderColorLight=#006600 border=1>
  <TBODY>
  <TR bgColor=#006600>
    <TD width="100%" colSpan=2 align="center" bgcolor="#E1FFE9"><h1 class="style1">论坛UBB代码彩色文字生成器</h1></TD>
<table cellspacing="0" bordercolordark="#ffffff" cellpadding="2" width="613" 
align="center" bordercolorlight="#006600" border="1">
  <tbody>
    <tr bgcolor="#006600">
      <td width="100%" colspan="2" align="center" bgcolor="#E1FFE9"><table border="0" cellpadding="0">
        <tbody>
	      <FORM name=GradForm>
          <tr>
            <td>&nbsp;
                <input onclick="set(0)" type="radio" value="bg" 
            name="setitem" />
              背景色
              <input onchange="newRGB(1,'')" size="6" value="#FFFFFF" 
            name="bg" />
                <input onclick="set(1)" type="radio" checked="checked" value="start" 
            name="setitem" />
              起始色
              <input onchange="newRGB(1,'')" size="6" value="#FF0000" 
            name="start" />
              &nbsp;
              <input onclick="set(2)" type="radio" value="end" 
            name="setitem" />
              结束色
              <input onchange="newRGB(1,'')" size="6" value="#0000FF" 
            name="end" />
            </td>
          </tr>
          <tr>
            <td><font color="#ff0000">红</font>
                <input name="button" type="button" onclick="setRGB('r',1)" value="+" />
              <input 
            onchange="newRGB(0,'r')" size="3" value="0" name="rgb_r" />
              <input name="button" type="button" onclick="setRGB('r',-1)" value="-" />
              <font color="#009900">绿</font>
              <input name="button" type="button" onclick="setRGB('g',1)" value="+" />
              <input 
            onchange="newRGB(0,'g')" size="3" value="0" name="rgb_g" />
              <input name="button" type="button" onclick="setRGB('g',-1)" value="-" />
              <font color="#0000ff">蓝</font>
              <input name="button" type="button" onclick="setRGB('b',1)" value="+" />
              <input 
            onchange="newRGB(0,'b')" size="3" value="255" name="rgb_b" />
              <input name="button" type="button" onclick="setRGB('b',-1)" value="-" />
            </td>
          </tr>
          <tr>
            <td><table cellspacing="-1" cellpadding="1" border="1">
                <tbody>
                  <tr>
                    <td bgcolor="#ffffff"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('FFFFFF');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#ffff00"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('FFFF00');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#ffe000"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('FFE000');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#ffc000"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('FFC000');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#ffa000"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('FFA000');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#ff8000"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('FF8000');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#ff6000"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('FF6000');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#ff4000"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('FF4000');return false" 
                  href="http://www.0916mx.com/zt/cs/#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#ff0000"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('FF0000');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#e00000"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('E00000');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#c00000"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('C00000');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#ffc0ff"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('FFC0FF');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#ffa0ff"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('FFA0FF');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#ff80ff"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('FF80FF');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#ff60ff"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('FF60FF');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#ff00ff"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('FF00FF');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#e000ff"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('E000FF');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#c000ff"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('C000FF');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#a000ff"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('A000FF');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#8000ff"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('8000FF');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#00ffff"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('00FFFF');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#00e0ff"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('00E0FF');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                  </tr>
                  <tr>
                    <td bgcolor="#00c0ff"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('00C0FF');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#00a0ff"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('00A0FF');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#0080ff"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('0080FF');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#0060ff"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('0060FF');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#0000ff"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('0000FF');return false" 
                  href="http://www.0916mx.com/zt/cs/">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#0000e0"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('0000E0');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#0000c0"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('0000C0');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#d0ff00"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('D0FF00');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#a0ff00"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('A0FF00');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#80ff00"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('80FF00');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#00ff00"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('00FF00');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#00e000"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('00E000');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#00c000"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('00C000');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#00a000"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('00A000');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#008000"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('008000');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#00a0a0"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('00A0A0');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#a0a000"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('A0A000');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#a0a0a0"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('A0A0A0');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#a0a0e0"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('A0A0E0');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#e0a0a0"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('E0A0A0');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#a0e0a0"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('A0E0A0');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                    <td bgcolor="#000000"><a onmouseover="nomsg();return true" 
                  onclick="SetColor('000000');return false" 
                  href="#">&nbsp;&nbsp;</a></td>
                  </tr>
                </tbody>
            </table></td>
          </tr>
          <tr>
            <td><p><strong>输入要生成的文字</strong></p>
              <p>
                <textarea name="showstr" cols="60" rows="6" onchange="AddText()"></textarea>
              </p></td>
          </tr>
          <tr>
            <td><input type="hidden" name="tempVal" />
              <span class="STYLE3"><font color="#FF0000">代</font><font color="#CC0033">码</font><font color="#990066">如</font><font color="#660099">下</font><font color="#3300CC">：</font></span><br />
              <textarea name="code" rows="6" cols="60"></textarea>
            </td>
          </tr>
          <tr>
            <td><input name="button" type="button" onclick="GenTag(this.form)" value="生成代码" />
                <input name="reset" type="reset" value="全部清除" />
            </td>
          </tr>
        
      </table></td>
    </tr>
  </tbody>
</table>

</BODY>
</HTML>
